<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>产品列表-商城管理-{$site.BACK_NAME}</title>
<include file="Public:jscss"/>
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="Item hr">
    <div class="current">产品列表</div>
   </div>
   <form action="" method="post" id="quickForm">
	<b>分类：</b>&nbsp;
	<select name="cid" style="width: 80px;">
	 <option value="0">不限</option>
	 <foreach name="clist" item="cone">
	 <option value="{$cone['id']}" {:is_selected($cone['id'],$cid)}>{$cone['fullname']}</option>
	 </foreach>
	</select>
	<b>状态：</b>&nbsp;
	<select name="status">
	 <option value="0">不限</option>
	 <option value="1" {:is_selected($status,1)}>在架</option>
	 <option value="2" {:is_selected($status,2)}>下架</option>
	</select>
    <b>快速搜索：</b>&nbsp;
    <input type="text" name="kwd" value="{$kwd}" placeholder="请输入关键字" class="input"/> &nbsp;
	<input type="submit" class="btn" value='搜索'/>
   </form>
   <form action="" method="post" id="tab_form">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
     <thead>
      <tr>
	   <td width="10%"><label><input class="cfz_choose_all" type="checkbox"/> 全选</label> <label><input class="cfz_unset_all" type="checkbox"/> 反选</label></td>
       <td width="20%">产品名称</td>
       <td width="10%">产品编号</td>
       <td width="10%">价格</td>
       <td width="10%">库存</td>
	   <td width="10%">单位</td>
       <td width="5%">排序</td>
	   <td width="5%">状态</td>
       <td width="20%">操作</td>
      </tr>
     </thead>
     <volist name="list" id="vo">
     <tr align="center" id="tr_{$vo.id}">
	  <td><input type="checkbox" name="id[]" value="{$vo.id}"/></td>
      <td align="left">{$vo.name}</td>
      <td align="left">{$vo.serial_number}</td>
      <td align="left">{$vo.price}</td>
	  <td align="left">{$vo.stock}</td>
	  <td>{$vo.unit}</td>
	  <td>{$vo.sort}</td>
      <td>{$vo.status}</td>
      <td>
	   [ <a href="{:U('Mall/proedt',array('id'=>$vo['id']))}">编辑 </a> ]
	   [ <a href="javascript:void(0)" data-id="{$vo['id']}" data-name="{$vo.name}" class="cfz_del">删除 </a> ]
	  </td>
     </tr>
     </volist>
    </table>
   </form>
   <div class="viciao">{$pager}</div>
   <div class="commonBtnArea">
    <button class="btn cfz_del_select">删除所选</button>
	<button class="btn cfz_add">添加产品</button>
   </div>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
</body>
<script type="text/javascript">
$(function(){
	//添加产品
	$(".cfz_add").click(function(){
		location.href = "{:U('Mall/proadd')}";
	});
	//单个删除
	$(".cfz_del").click(function(){
		var that = $(this);
		if(that.data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		var news_id = that.data("id");
		$.jBox.confirm(
			'您真的打算删除【<b>'+that.data("name")+'</b>】吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					that.data("busy",1).html("删除中...");
					$.getJSON("{:U('Mall/prodel')}", {id:news_id}, function(json){
						if(json.errcode==0){
							$("#tr_"+news_id).remove();
							$.jBox.tip(json.errmsg, 'success');
						}else{
							$.jBox.tip(json.errmsg, 'error');
						}
					});
					$.jBox.tip("系统处理中，请稍候....", 'loading');
					return true;
				}
			}
		);	
	});
	//多个删除
	$(".cfz_del_select").click(function(){
		var that = $(this);
		if(that.data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		if($("tbody input[type='checkbox']:checked").size()==0){
			$.jBox.tip('请先选择要删除的项', 'info');
			return false;
		}
		$.jBox.confirm(
			'您确定要删除该选定项吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					that.data('busy',1).html("提交处理中...");
					commonAjaxSubmit("{:U('Mall/prodel')}", "#tab_form");
				}
			}
		);
		return false;
	});
});
</script>
</html>